<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>系统首页</title>
        <!-- 下载并引入jquery easyUI -->
        <link rel="stylesheet" type="text/css"
              href="../js/jquery-easyui-1.9.5/themes/default/easyui.css">
        <link rel="stylesheet" type="text/css"
              href="../js/jquery-easyui-1.9.5/themes/icon.css">
        <link rel="stylesheet" type="text/css"
              href="../js/jquery-easyui-1.9.5/themes/color.css">
        <script type="text/javascript"
                src="../js/jquery-easyui-1.9.5/jquery.min.js"></script>
        <script type="text/javascript"
                src="../js/jquery-easyui-1.9.5/jquery.easyui.min.js"></script>
        <script type="text/javascript"
                src="../js/context-menu.js"></script>

        <style type="text/css">

            .top {
                height:80px;
                border-bottom:1px #95b8e7 solid;
                background-image:url(../images/top.jpg);
            }
            .button-tools {
                float:right;
                margin-right:10px;
                margin-top:40px;
            }
            .exit-system {
                float:right;
                margin-right:10px;
                margin-left:20px;
            }
        </style>
    </head>
    <body class="easyui-layout">
        <script type="text/javascript">
            if (window.top !== window.self) {
                window.top.location = "./userMessage.jsp";
            }
        </script>

        <div id="cc" class="easyui-layout"
             style="width: 100%; height: 100%; min-height: 600px;"
             data-options="fit:true">


            <div data-options="region:'north',border:false"   style="overflow: hidden; height: 80px;">
                <div class="top">
                    <div class="button-tools">
                        <div class="exit-system"><a id="exitSystem" target="_top" class="easyui-linkbutton"  href="../logout" data-options="iconCls:'icon-no'">安全退出</a></div>
                        <div class="exit-system"><a id="modifyPassSystem" onclick="updatePassword()" class="easyui-linkbutton" data-options="iconCls:'icon-large-clipart'">修改密码</a></div>
                        <div class="exit-system">
                            <div class="curUserInfo">当前登录用户：${user_login.name}</div>
                        </div>
                    </div>
                </div>
            </div>


            <div data-options="region:'west',title:'导航栏菜单',split:true"
                 style="width: 200px;">
                <div id="aa" class="easyui-accordion"
                     data-options="fit:true,border:false">

                    <div title="借阅管理" data-options="iconCls:'icon-save',selected:true"
                         style="overflow: auto; padding: 10px;">

                        <a id="btn" href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true,"
                           onclick="open_menu('借阅信息管理','user/lendBorrow/booksLending.jsp')">借阅信息管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('还书信息管理','user/lendBorrow/booksReturn.jsp')">还书信息管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('读者信息管理','user/lendBorrow/readerMessage.jsp')">读者信息管理</a>

                    </div>

                    <div title="图书管理" data-options="iconCls:'icon-reload'"
                         style="padding: 10px;">

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('图书信息管理','user/books/booksMessage.jsp')">图书信息管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('图书分类管理','user/books/booksRank.jsp')">图书分类管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('图书维修管理','user/books/booksFix.jsp')">图书维修管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('图书报废管理','user/books/booksScrap.jsp')">图书报废管理</a>
                    </div>

                    <div title="图书馆区域管理" data-options="iconCls:'icon-reload'"
                         style="padding: 10px;">

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('报纸信息管理','user/area/newspaperMessage.jsp')">报纸信息管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('杂志信息管理','user/area/magazineMessage.jsp')">杂志信息管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('电脑信息管理','user/area/computerMessage.jsp')">电脑信息管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('电脑使用信息管理','user/area/computerUse.jsp')">电脑使用信息管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('图书馆区域管理','user/area/areaMessage.jsp')">图书馆区域管理</a>

                    </div>

                    <div title="义工活动管理" data-options="iconCls:'icon-reload'"
                         style="padding: 10px;">

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('义工信息管理','user/volunteer/volunteerMessage.jsp')">义工信息管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('义工活动信息管理','user/volunteer/volunteerActivity.jsp')">义工活动信息管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('义工参与活动信息管理','user/volunteer/volunteerJoinActivity.jsp')">义工参与活动信息管理</a>
                    </div>

                    <div title="人事系统管理" data-options="iconCls:'icon-reload'"
                         style="padding: 10px;">

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('员工信息管理','user/sys/userMessage.jsp')">员工信息管理</a>

                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="open_menu('部门信息管理','user/sys/dept.jsp')">部门信息管理</a>
                        <br>
                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="plain:true"
                           onclick="updatePassword()">修改密码</a>
                        <br>
                        <a href="../logout"
                            class="easyui-linkbutton" data-options="plain:true">退出系统</a>
                    </div>

                </div>
            </div>

            <div data-options="region:'center',border:false,plain:true">
                <div id="tt" class="easyui-tabs" data-options="fit:true"
                     data-options="tools:'#tab-tools'">
                    <div title="首页" style="text-align: center; font-size: 24px;">
                        <p>欢迎来到图书馆后台管理系统</p>
                    </div>
                </div>
            </div>

            <div id="tab-tools">
                <a href="javascript:void(0)" class="easyui-linkbutton"
                   data-options="plain:true,iconCls:'icon-reload'" onclick="reload()"></a>
                <a href="javascript:void(0)" class="easyui-linkbutton"
                   data-options="plain:true,iconCls:'icon-delete'" onclick="closecur()"></a>
            </div>

            <div id="mm" class="easyui-menu" style="width: 150px;">
                <div data-options="iconCls:'icon-reload'" id="refresh">刷新</div>
                <div class="menu-sep"></div>
                <div data-options="iconCls:'icon-delete0'" id="closecur">关闭当前</div>
                <div data-options="iconCls:'icon-delete0'" id="closeall">全部关闭</div>
                <div data-options="iconCls:'icon-delete0'" id="closeother">除此之外全部关闭</div>
                <div class="menu-sep"></div>
                <div data-options="iconCls:'icon-delete0'" id="closeright">当前页右侧全部关闭</div>
                <div data-options="iconCls:'icon-delete0'" id="closeleft">当前页左侧全部关闭</div>
            </div>

            <div data-options="region:'south',border:false,plain:true"
                 style="height: 40px; text-align: center; font-size: 12px;">
                <p>版权所有,&copy;2020-2021</p>
            </div>
        </div>

        <div id="win" class="easyui-window" title="修改密码" style="width:400px;height:260px;" closed="true" data-options="collapsible:false,minimizable:false,resizable:false,maximizable:false"  buttons="#updatepass_dlg-buttons">
            <form id="updatePasswordForm" style="padding:10px 20px 10px 40px;">
                <p>旧密码: <input  name="opassword" style="width: 260px;"
                                class="easyui-passwordbox "
                                prompt="请输入旧密码" required="true" ></p>
                <p>新密码: <input id="npassword" name="npassword" style="width: 260px;"
                               class="easyui-passwordbox " prompt="请输入新密码" required="true" ></p>
                <p>确认密码: <input id="repassword" name="repassword" style="width: 260px;"
                                class="easyui-passwordbox " prompt="请再次输入新密码" required="true" ></p>
                <div id="updatepass_dlg-buttons" style="text-align: center; margin-top:50px;">
                    <a href="#" class="easyui-linkbutton" iconCls="icon-ok"
                       onclick="newPassword()">保存</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" style="margin-left:50px;"
                       onclick="$('#win').dialog('close')">取消</a>
                </div>
            </form>
        </div>

        <script type="text/javascript">
            function open_menu(titleName, menuUrl) {
                if ($("#tt").tabs("exists", titleName)) {
                    $("#tt").tabs("select", titleName);
                } else {
                    $('#tt').tabs('add', {
                        title : titleName,
                        href : menuUrl,
                        closable : true
                    });
                }
            }

            $(function() {
                bindContextMenu('#tt');
            });

            function updatePassword(){
                $('#win').window('open');
            }

            function newPassword() {
                $('#updatePasswordForm').form('submit',{
                    url: "../sys/updatePassword",
                    onSubmit: function(){
                        var ret = $('#npassword').val() === $('#repassword').val();
                        if (ret) {
                            return true;
                        } else {
                            $.messager.show({
                                title: '验证密码不一致',
                                msg: result.errorMsg
                            });
                            return false;
                        }
                    },
                    success: function(result){//收到服务器响应的json字符后，调用这里的代码 - - 回调函数，当浏览器收到服务器返回的数据后才执行
                        var result = eval('('+result+')');
                        if (!result.success){
                            //新增失败，使用消息框提示错误信息
                            $.messager.show({
                                title: 'Error',
                                msg: result.errorMsg
                            });
                        } else {
                            window.location.href="../logout"
                        }
                    }
                });
            }
        </script>
    </body>
</html>
